<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/17
 * Time: 14:09
 * Project name: PHPTEST
 * File name: 3.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */


ini_set( 'always_populate_raw_post_data', - 1 );

function getRequestUri( ) {
	$requestUri = '';
	if ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) // IIS
	{
		$requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
	} elseif ( isset( $_SERVER['REQUEST_URI'] ) ) {
		$requestUri = $_SERVER['REQUEST_URI'];
		if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
			if ( strpos( $requestUri, $_SERVER['HTTP_HOST'] ) !== false ) {
				$requestUri = preg_replace( '/^\w+:\/\/[^\/]+/', '', $requestUri );
			}
		} else {
			$requestUri = preg_replace( '/^(http|https):\/\/[^\/]+/i', '', $requestUri );
		}
	} elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) )  // IIS 5.0 CGI
	{
		$requestUri = $_SERVER['ORIG_PATH_INFO'];
		if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
			$requestUri .= '?' . $_SERVER['QUERY_STRING'];
		}
	}

	return $requestUri;
}

echo getRequestUri();
var_dump($_SERVER);